/**
 * 给定一个整数数组 nums，将数组中的元素向右轮转 k 个位置，其中 k 是非负数
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function (nums, k) {
  const len = nums.length
  let newArr = new Array(len)
  for (let i = 0; i < len; i++) {
    newArr[(k + i) % len] = nums[i]
  }

  for (let i = 0; i < len; i++) {
    nums[i] = newArr[i]
  }
};


let nums = [1, 2, 3, 4, 5, 6, 7]
let num = rotate(nums, 3)
console.log(nums)